import urllib.request
import locale
import re
import xml.etree.ElementTree as etree

##url = urllib.request.urlopen(r"http://www.cnbeta.com/backend.php")
###url = urllib.request.urlopen("http://www.cnbeta.com")
##mybytes = url.read()
##charset = url.getcode()
##print(url.info())
##print(charset)
##mystr = mybytes.decode('UTF-8','ignore')
####url.close()
####with open('output.xml', mode='w', encoding='UTF-8') as a_file:
####    a_file.write(mystr);

tree = etree.parse('output.xml')
root = tree.getroot()
node_channel = root.find('channel')
node_items = node_channel.findall('item')
for item in node_items:
    print(item.find('description').text)

##phonePattern = re.compile(r'<div class="newslist">[\d\D]*?</div>')
##with open('test.htm', mode='a', encoding='gb2312') as a_file:
##    for m in phonePattern.findall(mystr):
##        a_file.write(m)
    
